﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows;
using KqAutoDesign.Models;

namespace KqAutoDesign.SonViews
{
    public class MyTemplateSelector : DataTemplateSelector
    {
        public DataTemplate DoubleTemplate { get; set; }
        public DataTemplate StringTemplate { get; set; }
        public DataTemplate CheckBoxTemplate { get; set; }
        public DataTemplate IntTemplate { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            //// 根据条件选择模板，例如根据item的某个属性
            if(item is GroupScriptParam scp)
            {
                if (scp.ScriptParam.ParamType == ParamTypeEnum.StringType)
                    return StringTemplate;
                else if (scp.ScriptParam.ParamType == ParamTypeEnum.BoolType)
                    return CheckBoxTemplate;
                else if (scp.ScriptParam.ParamType == ParamTypeEnum.DoubleType)
                    return DoubleTemplate;
                else if (scp.ScriptParam.ParamType == ParamTypeEnum.IntType)
                    return IntTemplate;
            }
                return DoubleTemplate;
        }
    }
}
